using System.IO;

namespace Codemo.Core.Applications
{
    /// <summary>
    /// 
    /// </summary>
    public class Package
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Package"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="repositoryDirectory">The repository directory.</param>
        public Package(string name, string repositoryDirectory)
        {
            Name = name;
            RepositoryDirectory = repositoryDirectory;
        }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        public string Name { get; private set; }

        /// <summary>
        /// Gets or sets the repository directory.
        /// </summary>
        /// <value>The repository directory.</value>
        public string RepositoryDirectory { get; set; }

        /// <summary>
        /// Gets the relative path.
        /// </summary>
        /// <value>The relative path.</value>
        public string RelativePath
        {
            get
            {
                return Path.Combine(Name, string.Format("{0}.zip", Name));
            }
        }

        /// <summary>
        /// Gets the full path.
        /// </summary>
        /// <value>The full path.</value>
        public string FullName
        {
            get
            {
                return Path.Combine(RepositoryDirectory, RelativePath);
            }
        }

        /// <summary>
        /// Gets a value indicating whether [package exists].
        /// </summary>
        /// <value><c>true</c> if [package exists]; otherwise, <c>false</c>.</value>
        public bool Exists
        {
            get
            {
                return File.Exists;
            }
        }

        /// <summary>
        /// Gets the file.
        /// </summary>
        /// <value>The file.</value>
        public FileInfo File
        {
            get
            {
                return new FileInfo(FullName);
            }
        }
    }
}